/*
 * Folder.cpp
 *
 *  Created on: 2020年11月30日
 *      Author: san
 */

#include "Folder.h"
#include "Message.h"

Folder::Folder(const Folder &f): msgs(f.msgs)
{
	// 拷贝初始化
}

Folder &Folder::operator=(Folder &f)
{
	// 重载赋值运算符
	// 从Message中删除f
	for (auto m: msgs)
		m->remove(f);
	msgs = f.msgs;
	// 将Message添加到新的f中
	for (auto m: msgs)
		m->save(f);
}

void Folder::addMsg(Message *m)
{
	// 向本Folder中添加指定的Message
	msgs.insert(m);
}

void Folder::remMsg(Message *m)
{
//	m->
	std::cout << "Folder::remMsg(Message *m)" << std::endl;
	msgs.erase(msgs.find(m));
	delete m;
}

Folder::~Folder() {
	// TODO Auto-generated destructor stub
	std::cout << "~Folder() " << std::endl;
//	for (auto x: msgs)
//	{
//		delete x;
//	}
	std::cout << "~Folder() 2 " << std::endl;
}

